{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting sklearn\n",
      "  Downloading sklearn-0.0.tar.gz (1.1 kB)\n",
      "Collecting scikit-learn\n",
      "  Downloading scikit_learn-1.0.2-cp37-cp37m-win_amd64.whl (7.1 MB)\n",
      "Collecting threadpoolctl>=2.0.0\n",
      "  Downloading threadpoolctl-3.1.0-py3-none-any.whl (14 kB)\n",
      "Requirement already satisfied: numpy>=1.14.6 in c:\\users\\13633\\.conda\\envs\\pytorch-py37\\lib\\site-packages (from scikit-learn->sklearn) (1.21.2)\n",
      "Requirement already satisfied: scipy>=1.1.0 in c:\\users\\13633\\.conda\\envs\\pytorch-py37\\lib\\site-packages (from scikit-learn->sklearn) (1.7.3)\n",
      "Collecting joblib>=0.11\n",
      "  Downloading joblib-1.1.0-py2.py3-none-any.whl (306 kB)\n",
      "Building wheels for collected packages: sklearn\n",
      "  Building wheel for sklearn (setup.py): started\n",
      "  Building wheel for sklearn (setup.py): finished with status 'done'\n",
      "  Created wheel for sklearn: filename=sklearn-0.0-py2.py3-none-any.whl size=1309 sha256=058f4d95f1a8f23d13d9fa6e6eaccceda59fd3f4a7285962046d4065b698c855\n",
      "  Stored in directory: c:\\users\\13633\\appdata\\local\\pip\\cache\\wheels\\46\\ef\\c3\\157e41f5ee1372d1be90b09f74f82b10e391eaacca8f22d33e\n",
      "Successfully built sklearn\n",
      "Installing collected packages: threadpoolctl, joblib, scikit-learn, sklearn\n",
      "Successfully installed joblib-1.1.0 scikit-learn-1.0.2 sklearn-0.0 threadpoolctl-3.1.0\n"
     ]
    }
   ],
   "source": [
    "!pip install sklearn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[-0.75275929]\n",
      " [ 2.70428584]\n",
      " [ 1.39196365]\n",
      " [ 0.59195091]\n",
      " [-2.06388816]\n",
      " [-2.06403288]\n",
      " [-2.65149833]\n",
      " [ 2.19705687]\n",
      " [ 0.60669007]\n",
      " [ 1.24843547]\n",
      " [-2.87649303]\n",
      " [ 2.81945911]\n",
      " [ 1.99465584]\n",
      " [-1.72596534]\n",
      " [-1.9090502 ]\n",
      " [-1.89957294]\n",
      " [-1.17454654]\n",
      " [ 0.14853859]\n",
      " [-0.40832989]\n",
      " [-1.25262516]\n",
      " [ 0.67111737]\n",
      " [-2.16303684]\n",
      " [-1.24713211]\n",
      " [-0.80182894]\n",
      " [-0.26358009]\n",
      " [ 1.71105577]\n",
      " [-1.80195731]\n",
      " [ 0.08540663]\n",
      " [ 0.55448741]\n",
      " [-2.72129752]\n",
      " [ 0.64526911]\n",
      " [-1.97685526]\n",
      " [-2.60969044]\n",
      " [ 2.69331322]\n",
      " [ 2.7937922 ]\n",
      " [ 1.85038409]\n",
      " [-1.17231738]\n",
      " [-2.41396732]\n",
      " [ 1.10539816]\n",
      " [-0.35908504]\n",
      " [-2.26777059]\n",
      " [-0.02893854]\n",
      " [-2.79366887]\n",
      " [ 2.45592241]\n",
      " [-1.44732011]\n",
      " [ 0.97513371]\n",
      " [-1.12973354]\n",
      " [ 0.12040813]\n",
      " [ 0.28026168]\n",
      " [-1.89087327]\n",
      " [ 2.81750777]\n",
      " [ 1.65079694]\n",
      " [ 2.63699365]\n",
      " [ 2.3689641 ]\n",
      " [ 0.58739987]\n",
      " [ 2.53124541]\n",
      " [-2.46904499]\n",
      " [-1.82410283]\n",
      " [-2.72863627]\n",
      " [-1.04801802]\n",
      " [-0.66793626]\n",
      " [-1.37190581]\n",
      " [ 1.97242505]\n",
      " [-0.85948004]\n",
      " [-1.31439294]\n",
      " [ 0.2561765 ]\n",
      " [-2.15445465]\n",
      " [ 1.81318188]\n",
      " [-2.55269614]\n",
      " [ 2.92132162]\n",
      " [ 1.63346862]\n",
      " [-1.80770591]\n",
      " [-2.9668673 ]\n",
      " [ 1.89276857]\n",
      " [ 1.24114406]\n",
      " [ 1.37404301]\n",
      " [ 1.62762208]\n",
      " [-2.55573209]\n",
      " [-0.84920563]\n",
      " [-2.30478564]\n",
      " [ 2.17862056]\n",
      " [ 0.73978876]\n",
      " [-1.01461185]\n",
      " [-2.6186499 ]\n",
      " [-1.13410607]\n",
      " [-1.04890007]\n",
      " [ 1.37763707]\n",
      " [ 0.82534483]\n",
      " [ 2.32327646]\n",
      " [-0.16671045]\n",
      " [-2.28243452]\n",
      " [ 1.27946872]\n",
      " [ 1.56471029]\n",
      " [ 0.36766319]\n",
      " [ 1.62580308]\n",
      " [-0.03722642]\n",
      " [ 0.13639698]\n",
      " [-0.43475389]\n",
      " [-2.84748524]\n",
      " [-2.35265144]]\n",
      "[[1.61761105]\n",
      " [8.06185944]\n",
      " [4.45250583]\n",
      " [0.77958493]\n",
      " [1.84625712]\n",
      " [2.42319555]\n",
      " [4.34161741]\n",
      " [6.09231611]\n",
      " [1.98223289]\n",
      " [3.52597398]\n",
      " [4.17601517]\n",
      " [9.12288507]\n",
      " [5.45422161]\n",
      " [2.27678027]\n",
      " [2.01026368]\n",
      " [2.87326073]\n",
      " [0.81318015]\n",
      " [1.8319083 ]\n",
      " [1.28292861]\n",
      " [0.06839479]\n",
      " [3.19243691]\n",
      " [2.43738261]\n",
      " [1.5356506 ]\n",
      " [1.28504875]\n",
      " [0.3557864 ]\n",
      " [4.75426637]\n",
      " [1.47885324]\n",
      " [1.28677651]\n",
      " [2.54692985]\n",
      " [3.38548344]\n",
      " [4.73964113]\n",
      " [2.15170091]\n",
      " [3.05310205]\n",
      " [8.24583537]\n",
      " [6.77765841]\n",
      " [5.53583085]\n",
      " [1.57507685]\n",
      " [4.9628939 ]\n",
      " [3.52398974]\n",
      " [2.00693334]\n",
      " [2.26890937]\n",
      " [0.80280214]\n",
      " [4.25144683]\n",
      " [8.22363289]\n",
      " [2.39107959]\n",
      " [2.54118912]\n",
      " [2.91120971]\n",
      " [0.72580612]\n",
      " [2.90639207]\n",
      " [4.08728321]\n",
      " [7.79614645]\n",
      " [4.44706448]\n",
      " [8.21351277]\n",
      " [6.67148391]\n",
      " [1.20925575]\n",
      " [7.80341005]\n",
      " [1.51674287]\n",
      " [2.31316516]\n",
      " [2.07466744]\n",
      " [3.05108727]\n",
      " [0.77187987]\n",
      " [1.24709545]\n",
      " [6.73117257]\n",
      " [0.27900861]\n",
      " [1.7768814 ]\n",
      " [3.59613245]\n",
      " [0.55889954]\n",
      " [5.64163002]\n",
      " [2.96531544]\n",
      " [9.97020449]\n",
      " [3.73062776]\n",
      " [0.50573781]\n",
      " [3.95622505]\n",
      " [5.98103968]\n",
      " [4.26185621]\n",
      " [4.66448831]\n",
      " [4.27217418]\n",
      " [2.94240486]\n",
      " [1.80444194]\n",
      " [1.63688137]\n",
      " [8.41758883]\n",
      " [3.48726539]\n",
      " [0.30880326]\n",
      " [3.46656736]\n",
      " [0.53431055]\n",
      " [2.28828021]\n",
      " [5.4851746 ]\n",
      " [2.34525955]\n",
      " [7.98545933]\n",
      " [2.25996666]\n",
      " [3.14437931]\n",
      " [5.99478181]\n",
      " [4.54348132]\n",
      " [1.68151513]\n",
      " [4.05790648]\n",
      " [1.1476562 ]\n",
      " [2.06859733]\n",
      " [2.00090356]\n",
      " [3.48329165]\n",
      " [3.24201621]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAESCAYAAAD67L7dAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAXTklEQVR4nO3df7BkZ13n8fd3Jj+AMVk1DruAocAqDFCI4N7FvWClpnYiP5QCLUtLCjcoWFPWiiZbsiujjmGdsoZdLX6US+06hSgoopTBXX+gArOOwtZN9E4qChLjsmwZgtHEsJiQjQmZ+e4f3bdy03Tfe7r7nOf8er+qpu7ce7v7PN23+3Oe832e85z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fmpqWaz4E/APwssy8b9evfwp4EPhPbbRNqpM1fmkqM+9gctLWvN/dBTyhbIukZhj80hoi4iImn6OLgAMR8TjgQmY+3G7LpMUMfmk9P8FkeYcdDwJ/BBxppTVSBZ65K0kj4+CuJI2MwS9JI2PwS9LIGPySNDIGvySNjMEvSSNj8EvSyPx/CAfaRh4wGQkAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## 生成一些非线性数据\n",
    "import numpy as np\n",
    "# import numpy.random as rnd\n",
    "np.random.seed(42)\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "m = 100\n",
    "X = 6 * np.random.rand(m, 1) - 3\n",
    "y = 0.5 * X**2 + X + 2 + np.random.randn(m, 1)\n",
    "\n",
    "print (X)\n",
    "print (y)\n",
    "\n",
    "\n",
    "\n",
    "plt.plot(X, y, \"b.\")\n",
    "plt.xlabel(\"$x_1$\", fontsize=18)\n",
    "plt.ylabel(\"$y$\", rotation=0, fontsize=18)\n",
    "plt.axis([-3, 3, 0, 10])\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-0.75275929]\n",
      "[-0.75275929  0.56664654]\n",
      "[1.78134581] [[0.93366893 0.56456263]]\n"
     ]
    }
   ],
   "source": [
    "## use Scikit-Learn PolynomialFeature class:\n",
    "from sklearn.preprocessing import PolynomialFeatures\n",
    "\n",
    "poly_features = PolynomialFeatures(degree=2, include_bias=False)\n",
    "X_poly = poly_features.fit_transform(X) # a,b,degree=2: [a, b, a^2, ab, b^2]\n",
    "# a,b,degree=3: [a, b, a^2, ab, b^2, a^3, a^2b, ab^2, b^3]\n",
    "# a,b,c,degree=3: [a, b, c, a^2, ab, ac, b^2, bc, c^2, a^3, a^2b, a^2c, ab^2, ac^2, abc, b^3, b^2c, bc^2, c^3]\n",
    "print(X[0])\n",
    "print(X_poly[0])\n",
    "\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "lin_reg = LinearRegression()\n",
    "lin_reg.fit(X_poly, y)\n",
    "print(lin_reg.intercept_, lin_reg.coef_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAESCAYAAAD67L7dAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAwMElEQVR4nO3deXhTVfrA8e/pQmkLCLLJjsoIIjACdSmMgFAVBcYdZFFxAR0BnRlRcQNksY6guCGLMIK4jAqoP1ARBaooBSmggAJuiICIqMhalrbv74/TQlu6JG1yb27yfp4nT5vk5t6TtHlz8t5z3mNEBKWUUpEjyu0GKKWUcpYGfqWUijAa+JVSKsJo4FdKqQijgV8ppSKMBn6llIowAQ38xpj/GmN+Ncasz3fbycaYD40x3+b+rBbIYyqllPJPoHv8M4CuhW4bBiwSkb8Ai3KvK6WUcokJ9AQuY0xjYL6ItMi9vgnoJCI7jDF1gDQRaRrQgyqllPJZjAPHqC0iOwByg3+t4jY0xgwEBgIkJia2bdasmQPNU0opbzlwADZtAhEwBpo2hcREWLVq1W8iUrO0xzsR+H0mIlOBqQBJSUmSkZHhcouUUir0pKbCww9DdjZERcENN8D994MxZosvj3diVM/O3BQPuT9/deCYSikVtjp1ggoVIDra/uzUyb/HO9Hj/z/gRuCx3J/vOHBMpZQKW8nJsGgRpKXZoJ+c7N/jAxr4jTGvAZ2AGsaYbcAIbMB/wxhzC/ATcG0gj6mUUpEoOdn/gJ8noIFfRHoXc1eXQB5HKaVU2enMXaWUCgfbt/u8aUiN6vFVTk4O27Zt48CBA243RTkkNjaWWrVqUa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AacCtwARs/Zpia6Ao5QUa+JUqhjGmOzAPWAR0Bp4TkTvdbZVS5aepHqWKISLzgdVAF+B14IQFuo0xg3IXuT6UWwNdqZDn6kIsSoUyY0xP4Ozcq/uKWSxnB/AYcA6Q7FDTlCoXDfxKFcEYczEwC3gLOArcbIyZICIb8m+Xt5KTMaah861Uqmw01aNUIcaY84C5wGdAX+Ah7OIdqW62S6lA0cCvVD7GmDOx6zt/A1whIodF5Hvssn2XG2Pau9pApQJAA79SuXLTNQuBPcClIrI3392jgEzgcTfaplQgaY5fqVwi8hN20lZR9+0AEpxtkVLBoYFfqXIwxsRg30cxQJQxpiKQIyJH3G2ZUsXTwK9U+TyELe+QJxP4GOjkSmuU8oHO3FVKqQijJ3eVUirCaOBXSqkIo4FfKaUijAZ+pZSKMBr4lVIqwmjgV0qpCKOBXymlIsz/A38etpYhHK5TAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 画出预测的曲线\n",
    "X_new=np.linspace(-3, 3, 100).reshape(100, 1)\n",
    "X_new_poly = poly_features.transform(X_new)\n",
    "y_new = lin_reg.predict(X_new_poly)\n",
    "plt.plot(X, y, \"b.\")\n",
    "plt.plot(X_new, y_new, \"r-\", linewidth=2, label=\"Predictions\")\n",
    "plt.xlabel(\"$x_1$\", fontsize=18)\n",
    "plt.ylabel(\"$y$\", rotation=0, fontsize=18)\n",
    "plt.legend(loc=\"upper left\", fontsize=14)\n",
    "plt.axis([-3, 3, 0, 10])\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "#https://blog.csdn.net/HNU_Csee_wjw/article/details/88643400?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-1.pc_relevant_default&spm=1001.2101.3001.4242.2&utm_relevant_index=4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD4CAYAAADxeG0DAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAZ9klEQVR4nO3df5BddXnH8c+T5Qob/LE4bCssYNIZJhTBkrqjTtOxAmqoKKTYjjLq2NpOxj+swmBqoh3RtpZ00lE7badtRqk6UoVKumJDG9DAWBmhbthgxJDKyABZqKyVRYFVNsnTP7I33r05595z7/nec8733PdrhmH37t1zv2dz7nOf85zn+z3m7gIAxGtF2QMAAORDIAeAyBHIASByBHIAiByBHAAid0IZL3rqqaf6qlWrynhpAIjWnj17fuTu4+2PlxLIV61apenp6TJeGgCiZWYPJz1OaQUAIkcgB4DIEcgBIHKZA7mZXW9mT5jZd1see7GZ3W5m31/6/ymDGSYAIE0vGflnJV3S9thmSV9397MlfX3pewBAgTJ3rbj7N8xsVdvDl0t67dLXn5N0p6QPhhgYANTJ1Mystu06oMfmF3T62Kg2rV+jDWsngmw7b/vhL7v745Lk7o+b2S+lPdHMNkraKElnnXVWzpcFgHhMzcxqy459Wlg8LEmanV/Qlh37JClIMC/sYqe7b3f3SXefHB8/rp8dACptamZW67bu1urNO7Vu625Nzcxm/t1tuw4cC+JNC4uHtW3XgSBjy5uR/9DMTlvKxk+T9ESIQQFAleTNqB+bX+jp8V7lzchvkfSupa/fJekrObcHAJXz0Vvuz5VRnz422tPjveql/fCLkr4laY2ZHTSzP5S0VdLrzez7kl6/9D0A1MbUzKzmFxYTf5Y1o960fo1GGyPLHhttjGjT+jW5xyf11rVyZcqPLg4yEgCooE5Zd9aMull+qWrXCgDUWqesu5eMesPaiWCBux1T9AGgg7Ss+5SVjYEF5l4RyAGgg7T69rVvfllJIzoepRUA6GDQ9e0QCOQA0MUg69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z3SrpEUt8XpyuRkXdiZme3fHuZpAfKGksILWu4X8Ya7pXxbUlnm9lqM3uepLdJuqXkMWHJ0sXBz0ja7+6fKHs8eZnZeLNbzcxGJb1OOeNaDF0rN0tao6OdEQ9Leo+7z5Y7qv6Z2YOSTpT0f0sP3R15F87vSPpbSeOS5iXtdff1pQ6qD2b2RkmfkjQi6Xp3/3i5I+qfmX1R0mt1dInUH0q61t0/U+qgcjCz35T0X5L26WgckKQPufut5Y2qf2b2ckmf09FjbYWkm9z9z3Jts+qBHADQWeVLKwCAzgjkABA5AjkARI5ADgCRI5ADQOQI5AAQOQI5AETu/wHYtxRSCgJtMwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    " \n",
    "x = np.random.uniform(-3, 3, size=100)\n",
    "X = x.reshape(-1, 1)\n",
    " \n",
    "y = 0.5 * x**2 + x + 2 + np.random.normal(0, 1, size=100)\n",
    " \n",
    "plt.scatter(x, y)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD4CAYAAADxeG0DAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAeo0lEQVR4nO3de5BcVZ0H8O8vQyMdCAwUI5AJmGyJgfCQ4IjUhnLlZZDnyEIhpeBrK2L5AMRsEqVAFGUw69sVjYhgwfLQZEdMYMMjUCIF6CSTGCBEQV4ZghmQIUDGZDL57R/Tnenpuff2fZx77zm3v58qCqZvz72nh+5fn/s7v3OOqCqIiMhdE/JuABERJcNATkTkOAZyIiLHMZATET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iR9c4/n29rG2v0eirPabiGuy3CvB7HicdjTt/5FZGI7AFgMYBL6u7UnaOqw6p6FEbuyI8RkUQpsETL2JrSaM3zGv8DYBmAK1NsTmJFW8M9wv8fV20AcGDNz1MAvJRTW8hDJZe8GMAtqrok7/aYoqoDIvIggFMAxB6ctqJHHkREDq758UwAT+XVFhNq1nA/k2u4W+NPAA4WkWkisiuAjwC4M+c2UUVlcPAXANap6nfzbk9SItJWrVYTkTKAk5AwrrlQtbIYwHSMVEY8D+AiVe3Lt1XxicjTAN4G4NXKQ486XoXzYQA/AtAGYADAalWdnWujYhCRUwF8H0ALgBtU9Zv5tig+EbkVwAcwskTq3wFcqaq/yLVRCYjIcQAeArAWI3EAAL6iqnfl16r4RORIADdh5L02AcAdqvr1ROe0PZATEVEw61MrREQUjIGciMhxDORERI5jICcichwDORGR4xjIiYgcx0BOROS4/wcJuHwhHqq5SwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 先查看线性回归的效果\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "lin_reg = LinearRegression()\n",
    "lin_reg.fit(X, y)\n",
    "# Out[6]:\n",
    "# LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)\n",
    " \n",
    "y_predict = lin_reg.predict(X)\n",
    " \n",
    "plt.scatter(x, y)\n",
    "plt.plot(x, y_predict, color='r')\n",
    "plt.show() # 可以看到效果并不是很好"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "#https://blog.csdn.net/fanfan4569/article/details/81291712"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "线性回归平均绝对误差:  6.011979515629853\n",
      "线性回归均方误差:  43.53185829515393\n",
      "2 次多项式回归平均绝对误差:  19.79207082955178\n",
      "2 次多项式均方根误差:  464.32903847390224\n",
      "3 次多项式回归平均绝对误差:  4.547691416343451\n",
      "3 次多项式均方根误差:  29.933052221783786\n",
      "---\n",
      "4 次多项式回归平均绝对误差:  4.4264260796092705\n",
      "4 次多项式均方根误差:  29.0507744458861\n",
      "---\n",
      "5 次多项式回归平均绝对误差:  4.341615481914198\n",
      "5 次多项式均方根误差:  28.221918687365118\n",
      "---\n",
      "MSE 计算结果:  [43.53185829515393, 464.32903847390224, 29.933052221783786, 29.0507744458861, 28.221918687365118, 27.440821615302333, 26.712320078243224, 26.03872959299122, 25.422418036357616, 24.86581842005389]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'MSE')"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEWCAYAAACJ0YulAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAehklEQVR4nO3deZwdVZn/8c83nRXCFhIwJIEARmVTxLCNyzAGJTBA8luQgGiA/GR0cEEdFdyA+cGoM4rjxiDjQlgE44bRcSETRcYNJkgIhIAEWRISkrAkbCFkeeaPOn1T96a6O5103Xub+r5fr37dqlPb06eq67nnnLq3FRGYmZkBDGh1AGZm1j6cFMzMrMZJwczMapwUzMysxknBzMxqnBTMzKzGSaFilPm2pKck3daE410k6dqyj1OmMuusHetH0tsl3bSV67Zd/NtD0hWSPtXqOFrJSaFkkh6S9KKkkQ3l8yWFpPFpfqykH0h6XNIaSXdJOjMtG5/Wfbbh59RtCOkNwFuAsRFxxHb+elVRqTqLiOsi4q2tjqMVIuLdEfH/Wx1HKw1sdQAV8SBwGvAVAEmHAMMa1rkGuBPYB1gHHAK8rGGdXSNiw3bGsg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aMukrlVwHvbli3WXXV1T2hZdeWv+bCzMxqqth9ZGZmXXBSMDOzGicFMzOrcVIwM7MaJwUzM6txUjAzsxonBTMzq3FSMOsj6Tv475X0DUl3S7pO0rGSfpe+F7+Z33Brtk2cFMz61suBLwGvBl4FnE72qdV/AD7ewrjMtoqTglnfejAi7orsi98WAnMj+9qAu8j+cYtZW3NSMOtb63LTm3Lzm4CBzQ/HrHecFMzMrMZJwczMavwtqWZmVuOWgpmZ1TgpmJlZjZOCmZnVOCmYmVmNk4KZmdU4KZiZWY2TgpmZ1fwPw1OU0hBYtD0AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 1. 下载数据集\n",
    "# !wget http://labfile.oss.aliyuncs.com/courses/1081/course-6-vaccine.csv\n",
    "\n",
    "# 2. 用 Pandas 加载数据集\n",
    "import pandas as pd\n",
    "\n",
    "df = pd.read_csv(\"course-6-vaccine.csv\", header=0)\n",
    "df\n",
    "\n",
    "\n",
    "# 3. 绘制图像\n",
    "from matplotlib import pyplot as plt\n",
    "# 从原数据集中分离出需要的数据集（DataFrame）\n",
    "x = df['Year']\n",
    "y = df['Values']\n",
    "# 绘图\n",
    "plt.plot(x, y, 'r')\n",
    "plt.scatter(x, y)\n",
    "\n",
    "\n",
    "# 4. 训练集和测试集划分\n",
    "# 首先划分 dateframe 为训练集和测试集\n",
    "train_df = df[:int(len(df)*0.7)]\n",
    "test_df = df[int(len(df)*0.7):]\n",
    "\n",
    "# 定义训练和测试使用的自变量和因变量\n",
    "train_x = train_df['Year'].values\n",
    "train_y = train_df['Values'].values\n",
    "\n",
    "test_x = test_df['Year'].values\n",
    "test_y = test_df['Values'].values\n",
    "\n",
    "\n",
    "# 5. 线性回归预测\n",
    "# 建立线性回归模型\n",
    "from sklearn.linear_model import LinearRegression\n",
    "model = LinearRegression()\n",
    "model.fit(train_x.reshape(len(train_x),1), train_y.reshape(len(train_y),1))\n",
    "results = model.predict(test_x.reshape(len(test_x),1))\n",
    "results # 线性回归模型在测试集上的预测结果\n",
    "\n",
    "\n",
    "# 6. 线性回归误差计算\n",
    "from sklearn.metrics import mean_absolute_error\n",
    "from sklearn.metrics import mean_squared_error\n",
    "\n",
    "print(\"线性回归平均绝对误差: \", mean_absolute_error(test_y, results.flatten()))\n",
    "print(\"线性回归均方误差: \", mean_squared_error(test_y, results.flatten()))\n",
    "\n",
    "\n",
    "# 7. 二次多项式预测\n",
    "from sklearn.preprocessing import PolynomialFeatures\n",
    "\n",
    "# 2 次多项式回归特征矩阵\n",
    "poly_features_2 = PolynomialFeatures(degree=2, include_bias=False)\n",
    "poly_train_x_2 = poly_features_2.fit_transform(train_x.reshape(len(train_x),1))\n",
    "poly_test_x_2 = poly_features_2.fit_transform(test_x.reshape(len(test_x),1))\n",
    "\n",
    "# 2 次多项式回归模型训练与预测\n",
    "model = LinearRegression()\n",
    "model.fit(poly_train_x_2, train_y.reshape(len(train_x),1)) # 训练模型\n",
    "\n",
    "results_2 = model.predict(poly_test_x_2) # 预测结果\n",
    "\n",
    "results_2.flatten() # 打印扁平化后的预测结果\n",
    "\n",
    "print(\"2 次多项式回归平均绝对误差: \", mean_absolute_error(test_y, results_2.flatten()))\n",
    "print(\"2 次多项式均方根误差: \", mean_squared_error(test_y, results_2.flatten()))\n",
    "\n",
    "\n",
    "# 8. 更高次多项式回归预测\n",
    "\n",
    "from sklearn.pipeline import make_pipeline\n",
    "\n",
    "train_x = train_x.reshape(len(train_x),1)\n",
    "test_x = test_x.reshape(len(test_x),1)\n",
    "train_y = train_y.reshape(len(train_y),1)\n",
    "\n",
    "for m in [3, 4, 5]:\n",
    "    model = make_pipeline(PolynomialFeatures(m, include_bias=False), LinearRegression())\n",
    "    model.fit(train_x, train_y)\n",
    "    pre_y = model.predict(test_x)\n",
    "    print(\"{} 次多项式回归平均绝对误差: \".format(m), mean_absolute_error(test_y, pre_y.flatten()))\n",
    "    print(\"{} 次多项式均方根误差: \".format(m), mean_squared_error(test_y, pre_y.flatten()))\n",
    "    print(\"---\")\n",
    "\n",
    "\n",
    "# 9. 多项式回归预测次数选择\n",
    "# 计算 m 次多项式回归预测结果的 MSE 评价指标并绘图\n",
    "\n",
    "mse = [] # 用于存储各最高次多项式 MSE 值\n",
    "m = 1 # 初始 m 值\n",
    "m_max = 10 # 设定最高次数\n",
    "while m <= m_max:\n",
    "    model = make_pipeline(PolynomialFeatures(m, include_bias=False), LinearRegression())\n",
    "    model.fit(train_x, train_y) # 训练模型\n",
    "    pre_y = model.predict(test_x) # 测试模型\n",
    "    mse.append(mean_squared_error(test_y, pre_y.flatten())) # 计算 MSE\n",
    "    m = m + 1\n",
    "\n",
    "print(\"MSE 计算结果: \", mse)\n",
    "# 绘图\n",
    "plt.plot([i for i in range(1, m_max + 1)], mse, 'r')\n",
    "plt.scatter([i for i in range(1, m_max + 1)], mse)\n",
    "\n",
    "# 绘制图名称等\n",
    "plt.title(\"MSE of m degree of polynomial regression\")\n",
    "plt.xlabel(\"m\")\n",
    "plt.ylabel(\"MSE\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "https://blog.csdn.net/aaakirito/article/details/116941586?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_default&utm_relevant_index=2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[4 7 9 2 4 8 9 1 4]\n",
      "         3           2\n",
      "-0.0101 x + 0.02814 x + 0.3954 x + 4.738\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD4CAYAAAAAczaOA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AAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[4 7 9 2 4 8 9 1 4 6]\n",
      "===================================\n",
      "[5.15151515 5.56060606 5.9047619  6.12337662 6.15584416 5.94155844\n",
      " 5.41991342 4.53030303 3.21212121 1.4047619 ]\n"
     ]
    }
   ],
   "source": [
    "# -*- coding: utf-8 -*-\n",
    "'''\n",
    "    多项式拟合(最小二乘法),这里的例子是三次方拟合\n",
    "'''\n",
    " \n",
    "import numpy as np\n",
    "from matplotlib import pyplot as plt\n",
    " \n",
    " \n",
    "def func(x):  # 原函数\n",
    "    return x ** 3 - 3 * x + 1\n",
    " \n",
    " \n",
    "def trendline(x, y, n):\n",
    "    model = np.polyfit(x, y, deg=n)  # 拟合函数，输出参数\n",
    "    return np.poly1d(model)\n",
    " \n",
    " \n",
    "# 作图，其中y1为原始数据，y2为拟合出来的数据\n",
    "def PLT(x1, y1, x2, y2):\n",
    "    plt.scatter(x1, y1, color='blue')\n",
    "    plt.plot(x1, func(x1), color='yellow', label='real')\n",
    "    plt.plot(x2, y2, color='red', label='fit')\n",
    "    plt.legend()\n",
    "    plt.show()\n",
    " \n",
    " \n",
    "if __name__ == '__main__':\n",
    "    # 生成300个时序坐标点(x,y)，前250个点用于拟合，后50个点用于预测\n",
    "    x = np.linspace(-3, 3, 10)\n",
    "    y = func(x)\n",
    "    y += np.random.randn(10) * 0.5  # 加上噪声\n",
    "    \n",
    "#     print (type(x))\n",
    "#     print (type(y))\n",
    "    \n",
    "    x = [1,2,3,4,5,6,7,8,9,10]\n",
    "    y = [4,7,9,2,4,8,9,1,4,6]\n",
    "  \n",
    "    x = np.array(x)\n",
    "    y = np.array(y)\n",
    "    print (y[:9])\n",
    "    ff = trendline(x[:9], y[:9], n=3)\n",
    "    print(ff)\n",
    "\n",
    "    PLT(x, y, x, np.poly1d(ff)(x))\n",
    "    print(y)\n",
    "\n",
    "    print(\"===================================\")\n",
    "    print( np.poly1d(ff)(x))\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [],
   "source": [
    "#https://blog.csdn.net/u010751000/article/details/106250639?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_antiscanv2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_antiscanv2&utm_relevant_index=2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数据集\n",
    "datasets_X = [2009, 2010, 2011, 2012, 2013, 2014,2015, 2016, 2017]\n",
    "datasets_Y = [52, 36, 152, 100, 50, 35,150, 102, 51]\n",
    "test_X = [2018, 2019]\n",
    "# real_Y =  [ 2, 2684]\n",
    "\n",
    "# 数据预处理\n",
    "dataset_length = len(datasets_X)\n",
    "test_length = len(test_X)\n",
    "# 将数据转化为numpy数组，并变为列的形式\n",
    "datasets_X = np.array(datasets_X).reshape([dataset_length, 1])\n",
    "test_X = np.array(test_X).reshape([test_length, 1])\n",
    "datasets_Y = np.array(datasets_Y)\n",
    "# real_Y = np.array(real_Y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[61.6753351  50.38154762]\n"
     ]
    }
   ],
   "source": [
    "# 数据建模\n",
    "# 构造三次多项式特征\n",
    "poly_reg = PolynomialFeatures(degree=6)\n",
    "X_poly = poly_reg.fit_transform(datasets_X)\n",
    "\n",
    "# 使用线性回归模型学习X_poly和datasets_Y之间的映射关系\n",
    "lin_reg_3 = LinearRegression()\n",
    "lin_reg_3.fit(X_poly, datasets_Y) \n",
    "\n",
    "#### 2.3 数据预测\n",
    "\n",
    "#训练完毕后，就可以将lin_reg_3模型用于预测：\n",
    "\n",
    "data = poly_reg.fit_transform(test_X)\n",
    "pred = lin_reg_3.predict(data)\n",
    "print(pred) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "#metis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from sklearn.linear_model import Ridge\n",
    "from sklearn.preprocessing import PolynomialFeatures\n",
    "from sklearn.pipeline import make_pipeline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "metadata": {},
   "outputs": [],
   "source": [
    "def predict(X, window=4):\n",
    "    \"\"\"\n",
    "    Predict if a particular sample is an outlier or not.\n",
    "\n",
    "    :param X: the time series to detect of\n",
    "    :param type X: pandas.Series\n",
    "    :param window: the length of window\n",
    "    :param type window: int\n",
    "    :return: 1 denotes normal, 0 denotes abnormal\n",
    "    \"\"\"\n",
    "    x_train = list(range(0, 2 * window + 1)) + list(range(0, 2 * window + 1)) + list(range(0, window + 1))\n",
    "    x_train = np.array(x_train)\n",
    "    print (x_train)\n",
    "    x_train = x_train[:, np.newaxis]\n",
    "    print (X[-(window + 1):])\n",
    "    avg_value = np.mean(X[-(window + 1):])\n",
    "    print(avg_value) #dataA的平均值\n",
    "    \n",
    "    if avg_value > 1:\n",
    "#         y_train = X / avg_value\n",
    "        y_train = X\n",
    "    else:\n",
    "        y_train = X\n",
    "    print (y_train)\n",
    "    model = make_pipeline(PolynomialFeatures(4), Ridge())\n",
    "    print (x_train)\n",
    "    print (y_train)\n",
    "    model.fit(x_train, y_train)\n",
    "    \n",
    "    \n",
    "#     print (y_train[-1])\n",
    "#     print (model.predict(np.array(x_train[-1]).reshape(1, -1)))\n",
    "    \n",
    "    \n",
    "#     print(abs(y_train[-1] - model.predict(np.array(x_train[-1]).reshape(1, -1))))\n",
    "    \n",
    "    \n",
    "    \n",
    "    \n",
    "    if abs(y_train[-1] - model.predict(np.array(x_train[-1]).reshape(1, -1))) > 1.5:\n",
    "        return 0\n",
    "    return 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 160,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4]\n",
      "[130, 10, 20, 50, 60]\n",
      "54.0\n",
      "[2.40740741 0.18518519 0.37037037 0.92592593 2.77777778 0.55555556\n",
      " 0.18518519 0.37037037 0.92592593 2.40740741 0.18518519 0.37037037\n",
      " 0.92592593 2.77777778 0.55555556 0.18518519 0.37037037 0.92592593\n",
      " 2.40740741 0.18518519 0.37037037 0.92592593 1.11111111]\n",
      "[[0]\n",
      " [1]\n",
      " [2]\n",
      " [3]\n",
      " [4]\n",
      " [5]\n",
      " [6]\n",
      " [7]\n",
      " [8]\n",
      " [0]\n",
      " [1]\n",
      " [2]\n",
      " [3]\n",
      " [4]\n",
      " [5]\n",
      " [6]\n",
      " [7]\n",
      " [8]\n",
      " [0]\n",
      " [1]\n",
      " [2]\n",
      " [3]\n",
      " [4]]\n",
      "[2.40740741 0.18518519 0.37037037 0.92592593 2.77777778 0.55555556\n",
      " 0.18518519 0.37037037 0.92592593 2.40740741 0.18518519 0.37037037\n",
      " 0.92592593 2.77777778 0.55555556 0.18518519 0.37037037 0.92592593\n",
      " 2.40740741 0.18518519 0.37037037 0.92592593 1.11111111]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 160,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X = [130,10,20,50,150,30,10,20,50,130,10,20,50,150,30,10,20,50,130,10,20,50,60]\n",
    "predict(X)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
